FROM ros:humble-ros-base

ARG USERNAME=rosdev
ARG UID=1000
ARG GID=$UID

RUN sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo 'deb https://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse'               >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse'           >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse'      >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse'  >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse'       >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse'   >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse'     >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse' >> /etc/apt/sources.list

RUN groupadd -g $GID $USERNAME \
    && useradd -lm -u $UID -g $USERNAME -s /bin/bash $USERNAME \
    && chown -R $USERNAME:$USERNAME /home/$USERNAME \
    && echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER $USERNAME

RUN sudo apt update
RUN sudo apt install -y python3-opencv python3-pip
RUN sudo pip3 install rosdepc && sudo rosdepc init && rosdepc update
RUN mkdir -p /home/$USERNAME/.pip \
    && echo "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\ntrusted-host = mirrors.aliyun.com" > /home/$USERNAME/.pip/pip.conf

COPY src /apprun/src
RUN rosdep install --from-paths /apprun/src/zorbus_image --ignore-src -y --rosdistro humble
#RUN colcon build --packages-select zorbus_image \
#    && source install/setup.bash

WORKDIR /apprun



